package com.teaphy.coroutinecrawler.flow.operators

import kotlinx.coroutines.*
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.*

@FlowPreview
fun main() = runBlocking {
    flow {
        for (value in 0..5) {
            println("emit - $value")
            emit(value)
            delay(value * 100L)
        }
        emit(6)
        delay(200)
        emit(7)
        delay(300)
        emit(8)
        delay(100)
        emit(9)
    }.debounce(1000)
        .collect {
            println("接收到的数据：$it")
        }

    println("Done")
}